<?php
/*----------------------------------------------------------------------*
 * コンポーネント名 : キャンペーン情報追加・編集画面初期表示ビュー
 * URL           : /campaign_infos/index
 * 最新バージョン   : v1.0
 * 作成日         : 2012/08/08
 * 担当者         : 野島賢三
 * 内容           : 新規作成
 *【改訂履歴】
 *----------------------------------------------------------------------*/
?>
<!-- CAMPAIGN更新入力フォーム Start-->
<div id="newInfoInputBlock">
	<?php echo $this->form->create(array('default' => false));?>
	<?php echo $this->form->input('resistFor',
									array('type' => 'hidden',
											'id' => 'resistFor',
											'div' => false,
											'value' => 'CampaignInfo'));?>
	<?php echo $this->form->input('id',
									array('type' => 'hidden',
											'id' => 'in_id', 'div' => false));?>
	<h2>キャンペーン&nbsp;&nbsp;<span id='updType'>新規登録</span></h2>
	<table>
		<thead>
			<tr>
				<th>登録日付<small>&nbsp;※公開されません</small></th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td><?php echo $this->form->input('publish_ymd',
													array('label'=>'',
															'id'=>'in_publish_ymd',
															'timeFormat' =>'24',
															'dateFormat'=>'YMD',
															'monthNames'=>false));?>
				</td>
			</tr>
			<tr>
				<th>キャンペーン名&nbsp;&nbsp;<span id='errMessageTitle' style="color: red;"></span></th>
			</tr>
			<tr>
				<td><?php echo $this->form->input('title',
													array('type'=>'text',
															'label'=>'',
															'id'=>'in_title'
													));?>
				</td>
			</tr>
			<tr>
				<th>内&nbsp;容&nbsp;&nbsp;<span id='errMessageContent' style="color: red;"></span></th>
			</tr>
			<tr>
				<td><?php echo $this->form->input('content',
													array('type'=>'textarea',
															'label'=>'',
															'id'=>'in_content',
													));?>
				</td>
			</tr>
			<tr>
				<td>
					<div id="previewContent" style="display: none;">
					<h5>プレビュー</h5>
					<div id="previewContent">
						<h3 id="previewCampaignTitle"><span id="previewContentForCampaignTitle"></span></h3>
               			<div id="previewContentForContent" style="border-style:none;"></div>
					</div>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div id="publish_btns" style="display: none;">
						<?php echo $this->form->input('publish_flg',
														array('type'=>'radio',
																'label'=>false,
																'legend'=>false,
																'default'=>'0',
																'options'=>array('公開', '非公開')))?>
					</div>
				</td>
			</tr>
			<tr>
				<td><?php echo $this->form->button('クリア',
													 array('type'=>'reset',
													 		'id'=>'clearInfo'));?>
			 		<span id="previewBtn"><input type="button" id="reloadPreview" value="プレビュー" /></span>
					<span id='infoBtns' style="display: none;">
						<span id='resistInfoBtn'><?php echo $this->form->submit('登録する',
														array('id'=>'confirmAdd','div'=>false,
																'action'=>'add'));?></span>
						<span id='editNewInfoBtn' style="display:none;"><?php echo $this->form->submit('更新する',
													array('id'=>'confirmEdit','div'=>false,
															'action'=>'edit'));?></span>
					</span>
					<span id="previewCanBtn" style="display:none;"><input type="button" id="canPreview" value="やり直す" /></span>
				</td>
			</tr>
		</tbody>
	</table>
	<?php echo $this->form->end();?>
</div><!-- /#newInfoInputBlock -->
<!-- CAMPAIGN更新入力フォーム End-->

<!-- CAMPIGN登録データ一覧 Start-->
<div id="dataListBlock">
		<h2>キャンペーン&nbsp;一覧</h2>
		<!-- ページングボタン Start -->
		<div id='pagingBlock' >
			<?php $this->Paginator->options(array('url' => array('#' =>'dataListBlock')));?>
			<div id="pagingButtonBase">
				<span id="prev">
					<?php if ($this->Paginator->hasPrev()) echo $this->Paginator->prev('<');?>
				</span>
				<span id="page">
					<?php echo $this->Paginator->numbers();?>
				</span>
				<span id="next">
					<?php if ($this->Paginator->hasNext()) echo $this->Paginator->next('>');?>
				</span>
			</div>
		</div><!-- /#pagingBlock -->
		<!-- ページングボタン End -->
<?php if (isset($campaign_info_datas)):?>
	<?php echo $this->form->create(array('default' => false, 'div' => false));?>
		<table id="infoUpdTable">
			<?php foreach ($campaign_info_datas as $campaign_info_data):?>
					<?php
						$publish_flg;
						$campaignInfoId = $campaign_info_data['CampaignInfo']['id'];
						if($campaign_info_data['CampaignInfo']['publish_flg'] == '0'){
							$publish_flg = TRUE;
						} else {
							$publish_flg=FALSE;
						}
					?>
				<tbody style="border-bottom:solid 10px;" id="infoId_<?=$campaignInfoId ?>">
					<tr>
						<th>登録年月日<span style="float:right ">
						<?php
							if($publish_flg){
								echo $this->form->input('', array('type' => 'hidden',
																'id' => 'publishFlgChg_'.$campaignInfoId,
																'value' => '1'));
								echo $this->Html->image('now_publish.gif', array('border'=>'0'));
						 	} else {
						 		echo $this->form->input('', array('type' => 'hidden',
												 				'id' => 'publishFlgChg_'.$campaignInfoId,
												 				'value' => '0'));
								echo $this->Html->image('not_publish.gif', array('border'=>'0'));
						 	}
						 ?></span>
						</th>
					</tr>
					<tr>
						<td class="tdUpdDate" id="publish_ymd_<?=$campaignInfoId ?>"><?= $campaign_info_data['CampaignInfo']['publish_ymd']?></td>
					</tr>
					<tr>
						<th>キャンペーン名</th>
					</tr>
					<tr>
						<td id="title_<?=$campaignInfoId ?>"><?= $campaign_info_data['CampaignInfo']['title']?></td>
					</tr>
					<tr>
						<th>内容</th>
					</tr>
					<tr>
						<td id="content_<?=$campaignInfoId ?>"><?= nl2br($campaign_info_data['CampaignInfo']['content']);?></td>
					</tr>
					<tr>
						<td class="tdUpdBtn" style="padding:10px;">
						<?php echo $this->form->input('編集',
													array('type' => 'button',
															'label' => false,
															'id' => 'edit_'.$campaignInfoId,
															'div' => false,
															'style' => 'font-size:10px'
															));?>
						<?php echo $this->form->input('削除',
													array('type'=>'button',
															'label'=>false,
															'id'=>'del_'.$campaignInfoId,
															'div'=>false,
															'style' => 'font-size:10px'
															));?>
						</td>
					</tr>
				</tbody>
			<?php endforeach;?>
		</table>
	<?php echo $this->form->end();?>
<?php endif;?>
</div><!-- /#newInfoDataBlock -->
<!-- CAMPAIGN登録データ一覧 End-->
<p id="dataList-top"><a href="#wrap">一覧へ</a></p>
